Skip to content

feat(frameworks): add NestJS support#225

Merged
colbymchenry merged 1 commit into
mainfrom
feat/nestjs-support
May 20, 2026
Merged

feat(frameworks): add NestJS support#225
colbymchenry merged 1 commit into
mainfrom
feat/nestjs-support

Conversation

@colbymchenry
Copy link
Copy Markdown
Owner

Closes #220.

Adds a nestjsResolver to the framework-resolution registry, following the established pattern (regex-over-comment-stripped-source, emitting route nodes + references edges to handler methods). NestJS is auto-detected from any @nestjs/* dependency in package.json (falling back to a scan of *.controller.ts / *.resolver.ts / *.gateway.ts).

Coverage — all four NestJS transport layers

Source Route node → handler
@Controller('cats') + @Get(':id') GET /cats/:id findOne
@Controller('cats') + @Post() POST /cats create
@Resolver() + @Query(() => [Cat]) QUERY cats cats
@Resolver() + @Mutation() MUTATION addCat addCat
@WebSocketGateway({namespace:'chat'}) + @SubscribeMessage('message') WS chat:message handleMessage
  • HTTP: @Controller prefix joined with @Get/@Post/@Put/@Patch/@Delete/@Head/@Options/@All, including the common empty @Controller() / @Get() cases.
  • GraphQL: @Query/@Mutation/@Subscription in @Resolver classes.
  • Microservices: @MessagePattern/@EventPattern.
  • WebSockets: @SubscribeMessage, prefixed with the gateway namespace.

Correctness details

  • String-aware balanced-paren arg reader so GraphQL type thunks (@Query(() => [User])) aren't truncated at the inner ().
  • Skips stacked decorators (@UseGuards, @HttpCode) when locating the handler method.
  • Disambiguates @Query() — it's both a GraphQL method decorator and a REST parameter decorator; it only counts as GraphQL inside an @Resolver class.
  • resolve() links injected *Service/*Controller/etc. references to their classes by Nest file-naming convention.

Tests / verification

  • 62 framework tests pass (18 new: HTTP, GraphQL, microservice/WS, detect, resolve, commented-out regression).
  • Full suite 661/661; tsc build clean.
  • End-to-end index of a scratch NestJS project produced exactly the 5 routes above with resolved handler edges.

🤖 Generated with Claude Code

Detect NestJS projects and emit `route` nodes (each linked by a `references`
edge to its handler method) across all four transport layers:

- HTTP controllers: @controller prefix joined with
  @Get/@Post/@Put/@Patch/@Delete/@Head/@Options/@ALL
- GraphQL resolvers: @Query/@Mutation/@subscription
- Microservices: @MessagePattern/@EventPattern
- WebSocket gateways: @SubscribeMessage (prefixed with gateway namespace)

Detected from any @nestjs/* dependency in package.json (falls back to scanning
*.controller.ts/*.resolver.ts/*.gateway.ts). Handles class+method path joining
with empty @controller()/@get(), a string-aware balanced-paren arg reader so
GraphQL type thunks (@query(() => [User])) aren't truncated, stacked decorators
(@UseGuards) when locating the handler, and disambiguates the @query() GraphQL
method decorator from the REST @query() param decorator (GraphQL only counts
inside @resolver classes). Also resolves injected *Service/*Controller refs to
their classes by Nest file-naming convention.

Adds 18 framework tests; updates the README framework table and CHANGELOG.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@colbymchenry colbymchenry merged commit 948b287 into main May 20, 2026
@colbymchenry colbymchenry deleted the feat/nestjs-support branch May 20, 2026 22:09
@colbymchenry colbymchenry mentioned this pull request May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nestjs

1 participant